package iteratorPattern.demo;

import java.util.Iterator;

/**
 * @author： pang-yun
 * @date： 2021-12-09 19:24
 * 功能目的 ：用于 计院
 */

public class ComputerCollegeIterator implements Iterator {

    //这里确定 department 是以什么样的方式存放
    Department[] departments;
    // 遍历的位置
    int position = 0;

    public ComputerCollegeIterator(Department[] departments) {
        this.departments = departments;
    }

    @Override
    public boolean hasNext() {
        if (position >= departments.length || departments[position] == null) {
            return false;
        }
        return true;
    }

    @Override
    public Object next() {
        Department department = departments[position];
        position++;
        return department;
    }

    @Override
    public void remove() {

    }
}
